package com.olocat.cjx.nsims.service.impl

import com.olocat.cjx.nsims.dao.DoctorRepository
import com.olocat.cjx.nsims.pojo.personnel.Doctor
import com.olocat.cjx.nsims.service.DoctorService
import org.springframework.stereotype.Service
import javax.annotation.Resource

@Service
class DoctorServiceImpl :  DoctorService {

    @Resource
    lateinit var doctorRepository: DoctorRepository

    override fun list(): List<Doctor> {
        return doctorRepository.findAll()
    }

    override fun getById(id: String): Doctor {
        return doctorRepository.getOne(id)
    }

    override fun updateById(doctor: Doctor) {
        doctorRepository.save(doctor)
    }

    override fun removeById(id: String) {
        doctorRepository.deleteById(id)
    }

    override fun save(doctor: Doctor) {
        doctorRepository.save(doctor)
    }

    override fun getByName(name: String): List<Doctor> {
        return doctorRepository.getByName(name)
    }

    override fun getDoctorByDepartment(department: Int): List<Doctor> {
        return doctorRepository.getDoctorByDepartment(department)
    }

    override fun getDoctorByName(name: String): List<Doctor> {
        return doctorRepository.getDoctorByName(name)
    }
}